import dayjs from 'dayjs'
import message from '../../components/b-message/b-message'

Page({
	data: {
		navtopPaddingTop: 0,
		restData:{
			start_date: dayjs().format('YYYY-MM-DD'),
			end_date: dayjs().format('YYYY-MM-DD'),
			approver_id: '',
			reason: ''
		},
		approverArr: [
			{id: 12, label: '万叶'},
			{id: 14, label: '神里'},
			{id: 3, label: '可利'}
		],
		index: 0
	},
	// 加载完成时
	onReady(){
		this.setData({
			['restData.approver_id']: this.data.approverArr[0].id
		})
	},
	// 调休原因输入框
	reasonBindinput: function(e){
		this.setData({
			['restData.reason']: e.detail.value
		})
	},
	// 申请调休提交
	formSubmit(){
		console.log(this.data.restData)
		message.success('提交成功')
	},
	// 审核人改变
	approverChange(val){
		this.setData({
			['restData.approver_id']: this.data.approverArr[val.detail.value].id,
			index: val.detail.value
		})
	},
	// 结束调休日期改变
	endDateChange(val){
		this.setData({
			['restData.end_date']: val.detail.value
		})
	},
	// 开始调休日期改变
	startDateChange(val){
		this.setData({
			['restData.start_date']: val.detail.value
		})
	},
	// 接收顶部条组件传递的值，并赋值给 this.data.navtopPaddingTop
	getNavtopHeight(e){
		this.setData({
			navtopPaddingTop: e.detail.navtopHeight
		})
	}
})